<template>
  <el-container class="home-container" style="min-height: 100vh">
    <el-header>
      <div>
        新闻后台管理系统
      </div>
      <!--根据用户权限决定是否显示该按钮-->
      <div>
        <el-button type="info" @click="logout">退出</el-button>
      </div>

    </el-header>
    <el-container style="height: auto; border: 1px solid #eee">
      <el-aside width="240px" style="background-color: rgb(238, 241, 246)">
        <el-menu :default-openeds="['1', '3']">
          <el-submenu index="1" class="custom-submenu" @click.native="NewsManager">
            <template slot="title"><i class="el-icon-message"></i><span>稿件管理</span></template>
          </el-submenu>
          <el-submenu index="3" class="custom-submenu" @click.native="DepartmentManager">
            <template slot="title"><i class="el-icon-setting"></i><span>部门管理</span></template>
          </el-submenu>
          <el-submenu index="4" class="custom-submenu">
            <template slot="title"><i class="el-icon-s-home"></i>信箱管理</template>
            <el-menu-item index="4-1" @click.native="StatesmanEmail"><i
                class="el-icon-position"></i><span>政委信箱</span></el-menu-item>
            <el-menu-item index="4-2" @click.native="CaptainEmail"><i
                class="el-icon-position"></i><span>总队长信箱</span></el-menu-item>
            <el-menu-item index="4-3" @click.native="CommissionEmail"><i
                class="el-icon-position"></i><span>纪委信箱</span></el-menu-item>
            <el-menu-item index="4-4" @click.native="PoliticsEmail"><i
                class="el-icon-position"></i><span>政治部信箱</span></el-menu-item>
          </el-submenu>
          <el-submenu index="5" class="custom-submenu" @click.native="ThematicManager">
            <template slot="title"><i class="el-icon-s-order"></i><span>专题管理</span></template>
          </el-submenu>
          <el-submenu index="6" class="custom-submenu" @click.native="UserManager">
            <template slot="title"><i class="el-icon-s-custom"></i><span>用户管理</span></template>
          </el-submenu>
          <el-submenu index="7" class="custom-submenu" @click.native="ScheduleManager">
            <template slot="title"><i class="el-icon-tickets"></i><span>值班表管理</span></template>
          </el-submenu>
          <el-submenu index="8" class="custom-submenu" @click.native="NewsCount">
            <template slot="title"><i class="el-icon-s-data"></i><span>各部门稿件数量统计</span></template>
          </el-submenu>
        </el-menu>
        <div class="gray" style="text-align: right; margin: 10px;">
            <el-button type="info" @click="toggleGray">一键变灰</el-button>
          </div>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>

  </el-container>
</template>

<script>


export default {
  data() {
    return {}
  },
  methods: {
    logout() {
      //清空token
      window.sessionStorage.clear()
      //跳转到登录页
      this.$router.push('/')
    },
    //一键变灰
    toggleGray() {
      this.$store.commit('toggleGray');
    },
    reviewNews() {
      this.$router.push('/admin/review')
    },
    NewsManager() {
      this.$router.push('/admin/main')
    },
    DepartmentManager() {
      this.$router.push('/admin/departmentselector')
    },
    StatesmanEmail() {
      this.$router.push('/admin/statesmanemail')
    },
    CaptainEmail() {
      this.$router.push('/admin/captainemail')
    },
    CommissionEmail() {
      this.$router.push('/admin/commissionemail')
    },
    PoliticsEmail() {
      this.$router.push('/admin/politicsemail')
    },
    ThematicManager() {
      this.$router.push('/admin/thematicmanager')
    },
    UserManager() {
      this.$router.push('/admin/usermanager')
    },
    ScheduleManager() {
      this.$router.push('/admin/dutyschedule')
    },
    NewsCount() {
      this.$router.push('/admin/newscount')
    }

  }
}
</script>

<style lang="less" scoped>
// .home-container {
//   height: 100%;
// }
.el-header {
  background-color: rgb(55, 61, 63);
  display: flex;
  justify-content: space-between;
  padding-left: 0;
  align-items: center;
  color: #fff;
  font-size: 20px;

  >div {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 300px;
    height: 60px;

    img {
      width: 60px;
      height: 100%;
      border-radius: 50%;
    }

    span {
      margin-left: 15px;
    }
  }
}

.custom-submenu {
  margin-bottom: 12px;
}

.el-submenu__title:hover {
  cursor: pointer;
  color: skyblue;
}

// .el-main {
//   // background-color: rgb(233, 237, 240);
// }

.iconfont {
  margin-right: 10px;
}
</style>
